package controllers.actor;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import services.BidService;
import controllers.AbstractController;
import domain.Bid;

@Controller
@RequestMapping("/bid/actor")
public class BidActorController extends AbstractController {
	
	// Supporting services ----------------------------------------------------
	
	@Autowired
	private BidService bidService;

	// Constructors -----------------------------------------------------------
	
	public BidActorController() {
		super();
	}
		
	// Listing ---------------------------------------------------------------		

	@RequestMapping("/list")
	public ModelAndView list(@RequestParam int auctionId,@RequestParam(required=false) Integer aux) {
		ModelAndView result;
		Collection<Bid> bids = bidService.findBidsByAuctionId(auctionId);
				
		result = new ModelAndView("bid/list");
		
		result.addObject("bids", bids);
		if(aux.equals(1)){
			result.addObject("aux", aux);
		}
		
		return result;
	}

	
}
